//
//  BaseObject.m
//  CarFace
//
//  Created by dlios on 15/3/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "BaseObject.h"

@implementation BaseObject
- (instancetype)initWithDictionary:(NSDictionary *)dic
{
    self = [super self];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}
+ (NSMutableArray *)modelArrWithDics:(NSMutableDictionary *)dicArr
{
    NSMutableArray *modelArr = [NSMutableArray array];
    for (NSDictionary *modelDic in dicArr) {
        @autoreleasepool {
            if ([modelDic isKindOfClass:[NSDictionary class]]) {
                id model = [[self class] objectWithDictionary:modelDic];
                [modelArr addObjectsFromArray:model];
            }else{
                NSLog(@"不符合方法要求, 请检查数据源, 参数中的所有元素都必须是电影的字典信息");
            }
        }
    }
    if(modelArr.count == 0){
        NSLog(@"数组个数为空, 请检查数据源");
    }
    return modelArr;
}
+ (instancetype)objectWithDictionary:(NSDictionary *)dic
{
    id object = [[[self class] alloc] initWithDictionary:dic];
    return [object autorelease];
}
- (void)setValue:(id)value forKey:(NSString *)key
{
    
}
- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}
- (void)dealloc
{
    [super dealloc];
}

@end
